/**
 * @param {number} initialEnergy
 * @param {number} initialExperience
 * @param {number[]} energy
 * @param {number[]} experience
 * @return {number}
 */
 var minNumberOfHours = function(initialEnergy, initialExperience, energy, experience) {
  let res =0
  for (let i = 0; i < energy.length; i++) {
    if(energy[i]>=initialEnergy){
      res += energy[i]+1 - initialEnergy
      initialEnergy = energy[i]+1
    }
    if(experience[i]>=initialExperience){
      res+=experience[i]+1 - initialExperience
      initialExperience = experience[i]+1
    }

    initialEnergy-=energy[i]
    initialExperience+=experience[i]
    
  }
  return res
};